package com.situ.domain;

import java.io.Serializable;

// 1.有一个水果销售摊位，销售3种水果，重量和单价各不相同,实现多次的销售业务
// 2.销售时如果为顾客为女性销售金额打8折
// 3.显示当前各种水果的库存数
// 4.查询全部销售记录信息
// 5.加入其它水果品种
// 6.添加进货单
// 7.查询指定日期间隔的销售纯利润
// 8.每日17::00之后为5折特价
// 9.按销售数量排序显示前三名
// 10.示当前各种水果的库存数，成本单价，单价，累计销售数量/金额,累计进货数量/金额

public class FruitModel implements Comparable<FruitModel>, Serializable{
    /** serialVersionUID*/  
    private static final long serialVersionUID = 116116L;
    
    private int id; // 序号
    private String name; // 水果名称
    private double costPrice; // 成本价
    private double sellingPrice; // 售价
    private double totleSellOut; // 累计售货数量
    private double totleSellOutFunds; // 累计售货费用
    private double totleComeIn; // 累计进货数量
    private double totleComeInFunds; // 累计进货费用
    private double stock; // 库存
    
    // 自增记录
    private static int numId = 1;
    

    @Override
    public int compareTo(FruitModel o) {
        return this.id - o.getId();
    }  

    @Override
    public String toString() {
        return id + "\t" + name + "\t" + costPrice + "\t" + sellingPrice + "\t\t" + totleSellOut + "\t\t"
                + totleSellOutFunds + "\t\t" + +totleComeIn + "\t\t" + totleComeInFunds + "\t\t" + stock;
    }


    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(costPrice);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        result = prime * result + id;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        result = prime * result + numId;
        temp = Double.doubleToLongBits(sellingPrice);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(stock);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(totleComeIn);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(totleComeInFunds);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(totleSellOut);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(totleSellOutFunds);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        FruitModel other = (FruitModel) obj;
        if (Double.doubleToLongBits(costPrice) != Double.doubleToLongBits(other.costPrice))
            return false;
        if (id != other.id)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        if (Double.doubleToLongBits(sellingPrice) != Double.doubleToLongBits(other.sellingPrice))
            return false;
        if (Double.doubleToLongBits(stock) != Double.doubleToLongBits(other.stock))
            return false;
        if (Double.doubleToLongBits(totleComeIn) != Double.doubleToLongBits(other.totleComeIn))
            return false;
        if (Double.doubleToLongBits(totleComeInFunds) != Double.doubleToLongBits(other.totleComeInFunds))
            return false;
        if (Double.doubleToLongBits(totleSellOut) != Double.doubleToLongBits(other.totleSellOut))
            return false;
        if (Double.doubleToLongBits(totleSellOutFunds) != Double.doubleToLongBits(other.totleSellOutFunds))
            return false;
        return true;
    }

    // 构造器
    public FruitModel() {
        this.id = numId++;
    }

    public FruitModel(String name) {
        this();
        this.name = name;
    }
    
    public FruitModel(String name, double costPrice, double sellingPrice, double totleComeIn,
            double totleSellOut, double totleComeInFunds, double totleSellOutFunds, double stock) {
        this();
        this.name = name;
        this.costPrice = costPrice;
        this.sellingPrice = sellingPrice;
        this.totleComeIn = totleComeIn;
        this.totleSellOut = totleSellOut;
        this.totleComeInFunds = totleComeInFunds;
        this.totleSellOutFunds = totleSellOutFunds;
        this.stock = stock;
    }

    // getter setter
    public int getId() {
        return id;
    }

//    public void setId(int id) {
//        this.id = id;
//    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(double costPrice) {
        this.costPrice = costPrice;
    }

    public double getSellingPrice() {
        return sellingPrice;
    }

    public void setSellingPrice(double sellingPrice) {
        this.sellingPrice = sellingPrice;
    }

    public double getTotleComeIn() {
        return totleComeIn;
    }

    public void setTotleComeIn(double totleComeIn) {
        this.totleComeIn += totleComeIn;
    }

    public double getTotleSellOut() {
        return totleSellOut;
    }

    public void setTotleSellOut(double totleSellOut) {
        this.totleSellOut += totleSellOut;
    }

    public double getTotleComeInFunds() {
        return totleComeInFunds;
    }

    public void setTotleComeInFunds(double totleComeInFunds) {
        this.totleComeInFunds += totleComeInFunds;
    }

    public double getTotleSellOutFunds() {
        return totleSellOutFunds;
    }

    public void setTotleSellOutFunds(double totleSellOutFunds) {
        this.totleSellOutFunds += totleSellOutFunds;
    }

    public double getStock() {
        return stock;
    }

    public void setStock(double stock) {
        this.stock = stock;
    }

}
